博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
phpcms V9首页 频道页 列表页 推荐位 简单获取文章浏览量和评论统计
阅读量:4333 次
发布时间:2019-06-07

本文共 2718 字,大约阅读时间需要 9 分钟。

phpcms V9首页 频道页 列表页 推荐位 简单获取文章浏览量和评论统计

列表取得数据方法:

{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}{loop $data $r}{php $db = pc_base::load_model('hits_model');   $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));}
  • {date('Y-m-d H:i:s',$r[inputtime])}·{$r[title]} 点击:{$views} 评论数:{if $comment_total}{$comment_total}{else}0{/if}
  • {/loop}{$pages}{/pc}

    频道页获取数据方法

    {pc:content action="lists" catid="$v[catid]" num="5" order="id DESC"}{loop $data $v}{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; }{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));}
  • {$v[title]}点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}
  • {/loop}{/pc}

     首页获取数据方法

    {pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}    {php $categorys = getcache('category_content_'.$siteid,'commons');}                
      {loop $info $v} {php $category = $categorys[$v[catid]];} {php $modelid = $category['modelid'];} {php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; } {php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));}
    • ·{str_cut($v['title'],40)} 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}
    • {/loop}
    {/pc}

    推荐位获取数据方法

    {pc:content action="position" posid="2" order="listorder DESC" num="4"}{php $categorys = getcache('category_content_'.$siteid,'commons');}{loop $data $r}{php $category = $categorys[$r[catid]];}{php $modelid = $category['modelid'];}{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$r[catid].'-'.$r[id].'-'.$modelid));}

    {str_cut($r[title],36,'')} 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}

    {if $n==1}{/if}{str_cut($r[description],112)}


    {/loop} {/pc}

     

    转载于:https://www.cnblogs.com/manongxiaobing/p/4380974.html

    你可能感兴趣的文章
    Scalable IO in Java
    查看>>
    ajax 请求如何解决乱码
    查看>>
    类库探源——System.Exception
    查看>>
    [转自脚本之家] Javascript cookie 详解
    查看>>
    linux压缩和解压缩类命令|--zip/unzip指令
    查看>>
    约瑟夫问题
    查看>>
    地址空间和虚拟内存(转载)http://topic.csdn.net/u/20090619/10/4c62a13b-536b-4b0a-af09-2271c6a104e1.html...
    查看>>
    Unity3d 简单的小球沿贝塞尔曲线运动(适合场景漫游使用)
    查看>>
    Redis实现之数据库(三)
    查看>>
    【BZOJ】1070: [SCOI2007]修车
    查看>>
    mybatis的foreach的使用
    查看>>
    (转)PJSIP入门:编译,运用PJSIP,PJMEDIA
    查看>>
    linux下安装mysql笔记
    查看>>
    HDU 5115 Dire Wolf 区间dp
    查看>>
    将Centos的yum源更换为国内的阿里云源
    查看>>
    printf()详解之终极无惑-转载
    查看>>
    如何快速重置打印队列
    查看>>
    2.3 字典
    查看>>
    PHP中对数据库操作的封装
    查看>>
    JS模拟窗口
    查看>>